/**
	get file from url
*/
function Query(url){
	var oRequest = new XMLHttpRequest();
	oRequest.open("GET",url,false);
	oRequest.setRequestHeader("User-Agent",navigator.userAgent);
	oRequest.send(null)

	if (oRequest.status==200) return oRequest.responseText;
	else alert("Error executing XMLHttpRequest call!");
}

/**
	return the value of the radio button that is checked
	return an empty string if none are checked, or
	there are no radio buttons
*/
function GetCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

/**
	set the radio button with the given value as being checked
	do nothing if there are no radio buttons
	if the given value does not exist, all the radio buttons
	are reset to unchecked
*/
function SetCheckedValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}

function Hi(){
	alert("Hi");
}

if(typeof(String.prototype.explode) === "undefined")
{
    String.prototype.explode = function(separator, howmany)
    {
		var tokens = String(this).split(separator, howmany);
		if(tokens.length < howmany){
			return tokens;
		}
		// prefix = tokens.slice(0, howmany-1).join(separator),
		// tokens[howmany-1] = String(this).substring(prefix.length + separator.length);
		var separatorIndex = 0;
		for(var i=1; i< howmany; i++){
			separatorIndex += String(this).substring(separatorIndex).search(separator);
			separatorIndex = String(this).indexOf(tokens[i], separatorIndex+1);
		}
		tokens[howmany-1] = String(this).substring(separatorIndex);
		return tokens;
    };
}


if(typeof(String.prototype.startsWith) === "undefined")
{
    String.prototype.startsWith = function(prefix) 
    {
		return String(this).indexOf(prefix) === 0;
    };
}

if(typeof(String.prototype.indexOfEnd) === "undefined")
{
    String.prototype.indexOfEnd = function(substr) 
    {
		return String(this).indexOf(substr) + substr.length;;
    };
}

if(typeof(String.prototype.afterString) === "undefined")
{
    String.prototype.afterString = function(substr) 
    {
		return String(this).substring( String(this).indexOfEnd( substr) );
    };
}

if(typeof(String.prototype.beforeString) === "undefined")
{
    String.prototype.beforeString = function(substr) 
    {
		return String(this).substring( 0, String(this).indexOf( substr) );
    };
}

if(typeof(String.prototype.cutString) === "undefined")
{
    String.prototype.cutString = function(substr) 
    {
		return String(this).beforeString( substr )  + String(this).afterString( substr);
    };
}

if(typeof(String.prototype.trim) === "undefined")
{
    String.prototype.trim = function() 
    {
        return String(this).replace(/^\s+|\s+$/g, '');
    };
}


if(typeof(String.prototype.directory) === "undefined")
{
    String.prototype.directory = function() 
    {
        return String(this).substring(0, String(this).lastIndexOf('/'));
    };
}
